/**
 * 项目名：五位一体化工安全信息平台
 * 日期：    2019-12-03 14:14:47
 * Copyright (c) 2015- joysuch-版权所有
 */

package com.joysuch.wwyt.bp.entity;

import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import com.joysuch.wwyt.dataperm.annotation.DataPermissionField;
import com.joysuch.wwyt.mh.entity.MhMajorHazard;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;

import static javax.persistence.GenerationType.IDENTITY;

@EntityListeners({AuditingEntityListener.class, AutoSetCommonFieldListener.class})
@Entity
@Table(name = "WWYT_BP_STORAGE_TANK_AREA")
@SQLDelete(sql = "update WWYT_BP_STORAGE_TANK_AREA set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update WWYT_BP_STORAGE_TANK_AREA set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")

public class BpStorageTankArea implements java.io.Serializable {

    // columns START
    // ID
    private Long id;
    //统一编码
    private String code;
    //储罐区名称
    private String name;
    //所在位置
    private String location;
    //所处环境功能区
    private String inFunctionArea;
    //周边安全防护间距(m)
    private Float safeDistance;
    //储罐区面积(㎡)
    private Float area;
    //有无围堰
    private String hasCofferdam;
    //围堰所围面积(㎡)
    private Float cofferdamArea;
    //储罐个数
    private Integer tankCount;
    //储存物质
    private String storeMaterial;
    //储罐区总容积(m3)
    private Float volume;
    //常规储存量(m3)
    private Float nomalStorage;
    //两罐间最小间距(m)
    private Float minDistance;
    //有无消防通道
    private String hasFireChannel;
    //装卸方式
    private String loadMethod;
    //装卸危险化学品种类
    private String loadChemTypes;
    //是否构成重大危险源
    private String isMajorHazard;
    //创建人
    private Long createBy;
    //创建时间
    private java.util.Date createTime;
    //更新人
    private Long updateBy;
    //更新时间
    private java.util.Date updateTime;
    //删除标记
    private String deleteFlag;
    //组织机构代码
    private String orgCode;
    //租户
    private Long tenentId;
    //责任部门
    @DataPermissionField(sqlColumn = "responsible_dept")
    private Long responsibleDept;
    //columns END


    public void setId(Long value) {
        this.id = value;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "Id", unique = true, nullable = false)
    public Long getId() {
        return this.id;
    }


    @Column(name = "CODE", length = 10)
    public String getCode() {
        return this.code;
    }

    public void setCode(String value) {
        this.code = value;
    }


    @Column(name = "NAME", length = 30)
    public String getName() {
        return this.name;
    }

    public void setName(String value) {
        this.name = value;
    }


    @Column(name = "LOCATION", length = 500)
    public String getLocation() {
        return this.location;
    }

    public void setLocation(String value) {
        this.location = value;
    }


    @Column(name = "IN_FUNCTION_AREA", length = 100)
    public String getInFunctionArea() {
        return this.inFunctionArea;
    }

    public void setInFunctionArea(String value) {
        this.inFunctionArea = value;
    }


    @Column(name = "SAFE_DISTANCE")
    public Float getSafeDistance() {
        return this.safeDistance;
    }

    public void setSafeDistance(Float value) {
        this.safeDistance = value;
    }


    @Column(name = "AREA")
    public Float getArea() {
        return this.area;
    }

    public void setArea(Float value) {
        this.area = value;
    }


    @Column(name = "HAS_COFFERDAM", length = 2)
    public String getHasCofferdam() {
        return this.hasCofferdam;
    }

    public void setHasCofferdam(String value) {
        this.hasCofferdam = value;
    }


    @Column(name = "COFFERDAM_AREA")
    public Float getCofferdamArea() {
        return this.cofferdamArea;
    }

    public void setCofferdamArea(Float value) {
        this.cofferdamArea = value;
    }


    @Column(name = "TANK_COUNT")
    public Integer getTankCount() {
        return this.tankCount;
    }

    public void setTankCount(Integer value) {
        this.tankCount = value;
    }


    @Column(name = "STORE_MATERIAL", length = 200)
    public String getStoreMaterial() {
        return this.storeMaterial;
    }

    public void setStoreMaterial(String value) {
        this.storeMaterial = value;
    }


    @Column(name = "VOLUME")
    public Float getVolume() {
        return this.volume;
    }

    public void setVolume(Float value) {
        this.volume = value;
    }


    @Column(name = "NOMAL_STORAGE")
    public Float getNomalStorage() {
        return this.nomalStorage;
    }

    public void setNomalStorage(Float value) {
        this.nomalStorage = value;
    }


    @Column(name = "MIN_DISTANCE")
    public Float getMinDistance() {
        return this.minDistance;
    }

    public void setMinDistance(Float value) {
        this.minDistance = value;
    }


    @Column(name = "HAS_FIRE_CHANNEL", length = 2)
    public String getHasFireChannel() {
        return this.hasFireChannel;
    }

    public void setHasFireChannel(String value) {
        this.hasFireChannel = value;
    }


    @Column(name = "LOAD_METHOD", length = 20)
    public String getLoadMethod() {
        return this.loadMethod;
    }

    public void setLoadMethod(String value) {
        this.loadMethod = value;
    }


    @Column(name = "LOAD_CHEM_TYPES", length = 200)
    public String getLoadChemTypes() {
        return this.loadChemTypes;
    }

    public void setLoadChemTypes(String value) {
        this.loadChemTypes = value;
    }


    @Column(name = "IS_MAJOR_HAZARD", length = 2)
    public String getIsMajorHazard() {
        return this.isMajorHazard;
    }

    public void setIsMajorHazard(String value) {
        this.isMajorHazard = value;
    }


    @org.springframework.data.annotation.CreatedBy
    @Column(name = "CREATE_BY")
    public Long getCreateBy() {
        return this.createBy;
    }

    public void setCreateBy(Long value) {
        this.createBy = value;
    }


    @org.springframework.data.annotation.CreatedDate
    @Column(name = "CREATE_TIME")
    public java.util.Date getCreateTime() {
        return this.createTime;
    }

    public void setCreateTime(java.util.Date value) {
        this.createTime = value;
    }


    @org.springframework.data.annotation.LastModifiedBy
    @Column(name = "UPDATE_BY")
    public Long getUpdateBy() {
        return this.updateBy;
    }

    public void setUpdateBy(Long value) {
        this.updateBy = value;
    }


    @org.springframework.data.annotation.LastModifiedDate
    @Column(name = "UPDATE_TIME")
    public java.util.Date getUpdateTime() {
        return this.updateTime;
    }

    public void setUpdateTime(java.util.Date value) {
        this.updateTime = value;
    }


    @Column(name = "DELETE_FLAG", length = 2)
    public String getDeleteFlag() {
        return this.deleteFlag;
    }

    public void setDeleteFlag(String value) {
        this.deleteFlag = value;
    }


    @Column(name = "ORG_CODE", length = 100)
    public String getOrgCode() {
        return this.orgCode;
    }

    public void setOrgCode(String value) {
        this.orgCode = value;
    }


    @Column(name = "TENENT_ID")
    public Long getTenentId() {
        return this.tenentId;
    }

    public void setTenentId(Long value) {
        this.tenentId = value;
    }

    @Column(name = "responsible_dept")
    public Long getResponsibleDept() {
        return responsibleDept;
    }

    public void setResponsibleDept(Long responsibleDept) {
        this.responsibleDept = responsibleDept;
    }
    /*
     * private Set<BpStorageTank> bpStorageTanks = new LinkedHashSet<>(0);
     *
     * @OneToMany(mappedBy="bpStorageTankArea",fetch=FetchType.LAZY,cascade={CascadeType.PERSIST,CascadeType.REMOVE})
     * public Set<BpStorageTank> getBpStorageTanks() {
     * return this.bpStorageTanks;
     * }
     *
     * public void setBpStorageTanks(Set<BpStorageTank> bpStorageTanks){
     * this.bpStorageTanks = bpStorageTanks;
     * }
     */
    private MhMajorHazard mhMajorHazard;

    @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST})
    @JoinColumn(name = "MAJOR_HAZARD_ID")
    public MhMajorHazard getMhMajorHazard() {
        return this.mhMajorHazard;
    }

    public void setMhMajorHazard(MhMajorHazard mhMajorHazard) {
        this.mhMajorHazard = mhMajorHazard;
    }

    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("id", getId()).append("code", getCode())
                .append("name", getName()).append("location", getLocation())
                .append("inFunctionArea", getInFunctionArea()).append("safeDistance", getSafeDistance())
                .append("area", getArea()).append("hasCofferdam", getHasCofferdam())
                .append("cofferdamArea", getCofferdamArea()).append("tankCount", getTankCount())
                .append("storeMaterial", getStoreMaterial()).append("volume", getVolume())
                .append("nomalStorage", getNomalStorage()).append("minDistance", getMinDistance())
                .append("hasFireChannel", getHasFireChannel()).append("loadMethod", getLoadMethod())
                .append("loadChemTypes", getLoadChemTypes()).append("isMajorHazard", getIsMajorHazard())
                .append("createBy", getCreateBy()).append("createTime", getCreateTime())
                .append("updateBy", getUpdateBy()).append("updateTime", getUpdateTime())
                .append("deleteFlag", getDeleteFlag()).append("orgCode", getOrgCode()).append("tenentId", getTenentId())
                .toString();
    }

    public int hashCode() {
        return new HashCodeBuilder().append(getId()).toHashCode();
    }

    public boolean equals(Object obj) {
        if (obj instanceof BpStorageTankArea == false)
            return false;
        if (this == obj)
            return true;
        BpStorageTankArea other = (BpStorageTankArea) obj;
        return new EqualsBuilder().append(getId(), other.getId()).isEquals();
    }
}

